package hc;

import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricRegistry;

import java.util.concurrent.TimeUnit;

public class PerformanceAnalyze extends Thread {

    private MetricRegistry metricRegistry = new MetricRegistry();
    Histogram timeDelay = metricRegistry.histogram("timeDelay");
    Meter meter = metricRegistry.meter("meter");
//    private Timer subTime = metricRegistry.timer("sub-time");

    public PerformanceAnalyze() {
        ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry).build();
        reporter.start(5, TimeUnit.SECONDS);
    }

    public void timeDelay(long delay) {
        timeDelay.update(delay);
    }

    public void cpCounter() {
        meter.mark();
    }

}
